package cn.microservices.cloud.gateway.controller;


import cn.microservices.cloud.gateway.entity.AppType;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 8.0 迁移至 9.0  版本信息更新
 */
@Slf4j
@RestController
public class AppVersionController {

    @RequestMapping("/Isonoe/client/common/getAppVersion")
    public Map<String, Object> getVersion(@RequestParam(required = false) Integer appType, @RequestBody(required = false) AppType appty){
        Map<String,Object> jsonObject = new HashMap<>();
       log.error("appType="+appType);
        log.error("appty="+appty);
        if (appty!=null){
            if (appty.getAppType()==null){
                jsonObject.put("result",true);
                jsonObject.put("forceFlag",1);
                jsonObject.put("message","");
                jsonObject.put("version","9307");
            }else
            if (appty.getAppType()==0){
                log.error("appty0="+appty.getAppType());
                jsonObject.put("result",true);
                jsonObject.put("forceFlag",1);
                jsonObject.put("message","");
                jsonObject.put("version","9307");
            }else {
                log.error("appty1="+appty.getAppType());

                jsonObject.put("isoem",0);
                jsonObject.put("show",1);
                jsonObject.put("compulsory",1);
                jsonObject.put("url","https://itunes.apple.com/cn/app/%E5%BE%97%E4%BD%93%E4%BE%9B%E5%BA%94%E9%93%BE-%E8%AE%A9%E5%88%9B%E6%84%8F%E6%9C%89%E4%BB%B7%E5%80%BC/id1249187019?mt=8");
                jsonObject.put("version","9.61");
            }
        }
        if (appType!=null){

            if (appType == 0){
                jsonObject.put("result",true);
                jsonObject.put("forceFlag",1);
                jsonObject.put("message","");
                jsonObject.put("version","9307");

            }else {
                jsonObject.put("isoem",0);
                jsonObject.put("show",1);
                jsonObject.put("compulsory",1);
                jsonObject.put("url","https://itunes.apple.com/cn/app/%E5%BE%97%E4%BD%93%E4%BE%9B%E5%BA%94%E9%93%BE-%E8%AE%A9%E5%88%9B%E6%84%8F%E6%9C%89%E4%BB%B7%E5%80%BC/id1249187019?mt=8");
                jsonObject.put("version","9.61");

            }
        }
        return jsonObject;
    }

    @RequestMapping("/Isonoe/client/common/login")
    public JSONObject getLogin() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", true);
        jsonObject.put("cellphone", "13800000000");
        jsonObject.put("realname", "得体");
        jsonObject.put("imUsername", "得体");
        jsonObject.put("employeeImUsername", "得体");
        jsonObject.put("employeeCellphone", "得体");
        jsonObject.put("userId", "得体");
        return jsonObject;

    }
}
